/**
 * Project Name:jiuselu-parent
 * File Name:GoodsCategoryController.java
 * Package Name:com.fxp.project.jiuselu.web.business.v1.controller.goods
 * Date:2021年11月01日 16:57
 * Copyright (c) 2021, Kai.Wang All Rights Reserved.
 */
package com.fxp.project.jiuselu.web.business.v1.controller.goods;

import com.fxp.project.jiuselu.web.base.controller.BaseController;
import com.fxp.project.jiuselu.web.base.request.ReqBase;
import com.fxp.project.jiuselu.web.domain.CommonResult;
import com.fxp.project.jiuselu.web.models.goods.entity.JslBanner;
import com.fxp.project.jiuselu.web.models.goods.entity.JslGoodsCategory;
import com.fxp.project.jiuselu.web.models.goods.request.ReqCategory;
import com.fxp.project.jiuselu.web.models.goods.service.IJslGoodsCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * ClassName:GoodsCategoryController<br/>
 * Function: 商品分类信息<br/>
 * Date:2021年11月01日 16:57<br/>
 *
 * @author Kai.Wang
 * @version 1.0.0
 * @see
 * @since JDK 8
 */
@RestController
@RequestMapping("/v1/goods/category")
public class GoodsCategoryController extends BaseController {
    @Autowired
    IJslGoodsCategoryService jslGoodsCategoryService;

    /**
     * list: 通过父级Id获取数据<br/>
     *
     * @param reqCategory
     * @param result
     * @return
     * @author Kai.Wang
     * @date 2021/11/1 17:04
     */
    @PostMapping("list")
    @CrossOrigin
    public CommonResult list(@RequestBody @Validated ReqCategory reqCategory, BindingResult result, HttpServletResponse response) {
        response.setHeader("Access-Control-Allow-Origin", "*");
        super.checkBindResult(result);
        List<JslGoodsCategory> list = jslGoodsCategoryService.selectJslGoodsCategoryListByParentId(reqCategory.getParentId());
        return CommonResult.success(list);
    }
}
